<template>
  <div class="mt-4 ml-4">
    <div>{{ name }} > 详情</div>
    <div class="flex w-full items-end mb-3">
      <el-button type="primary" size="mini" @click="handleAdd">新增</el-button>
    </div>

    <el-table :data="tableData" border style="width:88vw">
      <el-table-column prop="id" label="序号" width="150px"></el-table-column>
      <el-table-column prop="name" label="等级名称"></el-table-column>
      <el-table-column prop="experience" label="经验值"></el-table-column>
      <el-table-column prop="screen_img" label="公屏图">
        <template slot-scope="{ row }">
          <el-popover placement="right" max-width="420" trigger="hover">
            <img :src="row.screen_img" alt="" style="max-width: 200px; max-height: 200px"/>
            <img slot="reference" :src="row.screen_img" alt="" style="width: 50px"/>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column prop="head_picture" label="标签图">
        <template slot-scope="{ row }">
          <el-popover placement="right" max-width="420" trigger="hover">
            <img :src="row.head_picture" alt="" style="max-width: 200px; max-height: 200px"/>
            <img slot="reference" :src="row.head_picture" alt="" style="width: 50px"/>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column prop="grade_big_id" label="礼包ID"></el-table-column>
      <el-table-column prop="reward" label="礼包类型">
        <template slot-scope="{ row }">
          <div v-if="row.reward">{{ row.reward.type }}</div>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="primary" plain size="mini" icon="el-icon-edit" @click="deBounceWrap(handleEdit, scope.row)">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>

    <detailAddEdit :dialogVisible.sync="model.visible" :id="this.id" :status.sync="model.status" @updateTable="getTable" :detail="model.detail" />
  </div>
</template>

<script>

import { getTable } from "@/api/dailyCheck/detail";

import detailAddEdit from "@/views/dailyCheck/vipLevelManagement/childComps/detailAddEdit";

export default {
  name: "detail",
  components: { detailAddEdit },
  data() {
    return {
      id: null,
      name: null,
      tableData: [],
      model: {
        visible: false,
        status: 'Add',
        detail: {}
      }
    }
  },
  created() {
    this.name = this.$route.query.name
    this.id = this.$route.query.id
    this.getTable()
  },
  methods: {
    async getTable() {
      const { data } = await getTable(this.id)
      this.tableData = data
    },
    handleAdd() {
      this.model.status = 'Add'
      this.model.visible = true
    },
    handleEdit(row) {
      this.model.detail = row
      this.model.status = 'Edit'
      this.model.visible = true
    },
  }
}
</script>

<style scoped>

</style>
